Many computer graphic images are created by mathematically modeling the interaction of light with a 3D scene from a given viewpoint. This process, called “rendering,” generates a two-dimensional (2D) image of the scene from the given viewpoint, and is analogous to taking a photograph of a real-world scene.
As the demand for computer graphics, and in particular for real-time computer graphics, has increased, computer systems with graphics processing subsystems adapted to accelerate the rendering process have become widespread. In these computer systems, the rendering process is divided between a computer's general purpose central processing unit (CPU) and the graphics processing subsystem, architecturally centered about a graphics processing unit (GPU). Typically, the CPU performs high-level operations, such as determining the position, motion, and collision of objects in a given scene. From these high-level operations, the CPU generates a set of rendering commands and data defining the desired rendered image or images. For example, rendering commands and data can define scene geometry, lighting, shading, texturing, motion, and/or camera parameters for a scene. The graphics processing subsystem creates one or more rendered images from the set of rendering commands and data.
Scene geometry is typically represented by geometric primitives, such as points, lines, polygons (for example, triangles and quadrilaterals), and curved surfaces, defined by one or more two- or three-dimensional vertices. Each vertex may have additional scalar or vector attributes used to determine qualities such as the color, transparency, lighting, shading, and animation of the vertex and its associated geometric primitives.
Many graphics processing subsystems are highly programmable through an application programming interface (API), enabling complicated lighting and shading algorithms, among other things, to be implemented. To exploit this programmability, applications can include one or more graphics processing subsystem programs, which are executed by the graphics processing subsystem in parallel with a main program executed by the CPU. Although not confined merely to implementing shading and lighting algorithms, these graphics processing subsystem programs are often referred to as “shading programs,” “programmable shaders,” or simply “shaders.”
A variety of shading programs are directed at modeling illumination in a scene. The physical plausibility of rendered illumination often depends on the application, more specifically, whether or not the rendering is done in real-time. Physically plausible illumination at real-time frame rates is often achieved using approximations. For example, ambient occlusion is a popular approximation because of its high speed and simple implementation. Another example is directional occlusion. Many algorithms can only approximate direct illumination, which is light coming directly from a light source.
Global illumination, or GI, is a concept that accounts for both direct illumination and indirect illumination, which is light that reflects off other surfaces, in rendering the scene. In doing so, a significantly more realistic image is achievable. However, real-time global illumination remains problematic for large and dynamic scenes. Efforts to mitigate the latency introduced by these comprehensive illumination algorithms are ongoing. For example, some algorithms partially pre-compute illumination. Another example is instant radiosity, which models indirect lighting as a set of point lights, the contributions of which are accumulated over multiple rendering passes. Yet another approach is to limit indirect lighting to a single bounce, under the assumption that one-bounce indirect illumination is sufficiently realistic. Still, real-time frame rates are typically only achievable through approximations.
Ambient occlusion, or AO, is an example of a shading algorithm, commonly used to add a global illumination look to rendered images. AO is not a natural lighting or shading phenomenon. In an ideal system, each light source would be modeled to determine precisely the surfaces it illuminates and the intensity at which it illuminates them, taking into account reflections, refractions, scattering, dispersion and occlusions. In computer graphics, this analysis is accomplished by ray tracing or “ray casting.” The paths of individual rays of light are traced throughout the scene, colliding and reflecting off various surfaces.
In non-real-time applications, each surface in the scene can be tested for intersection with each ray of light, producing a high degree of visual realism. This presents a practical problem for real-time graphics processing: rendered scenes are often very complex, incorporating many light sources and many surfaces, such that modeling each light source becomes computationally overwhelming and introduces large amounts of latency into the rendering process. AO algorithms address the problem by modeling light sources with respect to an occluded surface in a scene: as white hemispherical lights of a specified radius, centered on the surface and oriented with a normal vector at the occluded surface. Surfaces inside the hemisphere cast shadows on other surfaces. AO algorithms approximate the degree of occlusion caused by the surfaces, resulting in concave areas such as creases or holes appearing darker than exposed areas. AO gives a sense of shape and depth in an otherwise “flat-looking” scene.
The most realistic AO techniques are global; the illumination at each point is a function of other geometry in the scene. Screen-space AO (SSAO) can render only local effects and therefore fails to recognize the more subtle illuminations that lend realism. For this reason, SSAO will not be further described herein.
Several methods are available to compute global AO, but its sheer computational intensity makes it an unjustifiable luxury for most real-time graphics processing systems. To appreciate the magnitude of the effort AO entails, consider a given point on a surface in the scene and a corresponding hemispherical normal-oriented light source surrounding it. The illumination of the point is approximated by integrating the light reaching the point over the hemispherical area. The fraction of light reaching the point is a function of the degree to which other surfaces obstruct each ray of light extending from the surface of the sphere to the point.